﻿using System;
using System.Web.UI.WebControls;
using FormControllers;
using AgencyEntityLib.BaseEntity;
using SqlLibrary;
using Ecopsy.Tools;
using Ecopsy.DataTier;



/// <summary>
/// Базовый класс всех страничек - занимающихся редактированием структуры агентсва
/// </summary>
public class FormAdressPrograms : iAdmin_Page 
{
    public FormAdressPrograms()
    {
    }
    
    protected wsDictionary _ws_Dictionary = (wsDictionary)GlobalConstants.CurrentAgency.WS_FactoryList[WS_FactoryList.wsKey_Dictionary];

    public TreeDictionaryItem [] GetList(object _Where)
    {
        try
        {
            TreeDictionaryItem[] r = iAdmin_Page.TreeDictionaryContext.GetAdressProgrammAsArray();
            Where.SortCondition.fnOrderBy = SortFunctions.fOrderBy;            
            Array.Sort(r, Where.SortCondition);
             return r;
        }
        catch
        {
            throw;
        }


    }

    protected string GetWhereTxt()
    {
        return string.Empty;
        //EntityList l = (EntityList)Where.Match;
        //return ((ТрееDictionaryItem)l["Template"]).Name;
    }

    /// <summary>
    /// фильтр формы - сохраняемый в кэше
    /// </summary>
    protected ListWhere  Where
    {
        get
        {
            ListWhere r = null;
            string key = "sysDictionaryFolder";
            if (!CacheTools.IsCacheObject(key))
            {
                r = new ListWhere();
                r.ListLoadStatment = new ConstractionList.sqlLoadStatment();
                r.SortCondition.SortDirection = SortDirection.Ascending;
                r.SortCondition.SortField = "Name";
                CacheTools.SetCacheObject(key, r);
            }
            return (ListWhere)CacheTools.GetCacheObect(key);
        }

    }

    protected string qDepartamentID_Value
    {

        get
        {
            return Request[qDepartmentID];

        }
    }

}
